<?php

namespace App\ApiFrontend;

use App\Http\Controllers\ApiBaseController;

/**
 *  退出
 */
class Logout extends ApiBaseController
{

  /**
   * 参数检查
   */
  protected function check(): void
  {
  }

  /**
   * 业务主体
   */
  protected function service(): void
  {

    $user = request()->user();
    //删除之前token
    if ($user) {
      $user->tokens()->delete();
    }
    $this->result['message'] = '退出登录成功';
  }
}
